<%--
  Created by IntelliJ IDEA.
  User: ？
  Date: 2021/11/9
  Time: 9:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-3.6.0.min.js"></script>
    <script>

        $(function () {

            $("#word").keyup(function () {

                if ($(this).val() == ""){

                    $("#wordInfo").hide()
                    return
                }


                let url  = "${pageContext.request.contextPath}/wordServlet"

                let params={
                    "method":"getWordList",
                    "word":$(this).val()
                }

                let  callback = function (rel) {
                    console.log(rel)

                    $("#wordInfo").html("")
                    $(rel).each(function (index,ele) {
                        $("#wordInfo").append(ele.word+"<br/>")
                    })

                    $("#wordInfo").show()
                }

                $.post(url,params,callback,"json")


            })

        })


















    </script>
</head>
<body>

<input type="text"  id = "word" placeholder="请输入要搜索的内容">

</body>
</html>
